import time,ntptime,network
def wifi_main():
    global inif
    wifi=network.WLAN(network.STA_IF)        #WIFI模式
    if not wifi.isconnected():
        print('wifi  ing......')
        wifi.active(True)
        wifi.connect('WHTFKJ','15926234568159262345689558')  #连接WIFI
        while not wifi.isconnected():
            pass
    print('Wifi connection succeeded')
    print('network config:', wifi.ifconfig())
wifi_main()
while True:   #时间校准
    try:
        print('time ing')
        ntptime.settime()
        print('time ok')
        break;
    except:
        print('time no')
        time.sleep(1)
mytime=time.localtime()
mytime='%d-%d-%d %d:%d:%d'%(mytime[0],mytime[1],mytime[2],mytime[3]+8,mytime[4],mytime[5])
print(mytime)



